package tuples;

import java.util.Comparator;

/**
 *
 * @author Shimu
 * @date 9-Oct-2012
 */
public class Quadruple<T1, T2, T3, T4> extends Triple<T1, T2, T3> {

    private T4 ELEMENT4;

    public Quadruple(T1 element1, T2 element2, T3 element3, T4 element4) {
        super(element1, element2, element3);
        this.ELEMENT4 = element4;
    }

    /**
     * Returns the third element
     * @return 
     */
    public T4 getFourth() {
        return this.ELEMENT4;
    }

    public static <T extends Comparable> Comparator<Quadruple<?, ?, ?, T>> getFourthComparator(Class<T> c) {
        return new Comparator<Quadruple<?, ?, ?, T>>() {

            public int compare(Quadruple<?, ?, ?, T> o1, Quadruple<?, ?, ?, T> o2) {
                return o1.getFourth().compareTo(o2.getFourth());
            }
        };
    }

    @Override
    public String toString() {
        return String.format("Quadruple: (%s, %s, %s, %s)",
                String.valueOf(getFirst()), String.valueOf(getSecond()),
                String.valueOf(getThird()), String.valueOf(getFourth()));
    }
}
